import Vue from "vue";
import VueRouter from "vue-router";
import Login from "../views/Login.vue";
import System from "../views/System.vue";

Vue.use(VueRouter);
const originalPush = VueRouter.prototype.push
    // 重写了原型上的push方法，统一的处理了错误信息
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    name: "Login",
    component: Login,
  },
  {
    path: "/register",
    name: "Register",
    component: () => import("../views/Register.vue"),
  },
  {
    path: "/system",
    name: "System",
    component: System,
    children: [
      //首页
      {
        path: "home",
        name: "Home",
        component: () => import("../components/home/Home.vue"),
      },
      //用户管理
      {
        path: "user",
        name: "User",
        component: () => import("../components/permissions/User.vue"),
      },
      //角色管理
      {
        path: "role",
        name: "Role",
        component: () => import("../components/permissions/Role.vue"),
      },
      //菜单管理
      {
        path: "menu",
        name: "Menu",
        component: () => import("../components/permissions/Menu.vue"),
      },
      //基金管理
      {
        path: "fund",
        name: "Fund",
        component: () => import("../components/product/Fund.vue"),
      },
      //定期管理
      {
        path: "regular",
        name: "Regular",
        component: () => import("../components/product/Regular.vue"),
      },
      //活期管理
      {
        path: "current",
        name: "Current",
        component: () => import("../components/product/Current.vue"),
      },
      //黄金管理
      {
        path: "gold",
        name: "Gold",
        component: () => import("../components/product/Godl.vue"),
      },
      //系统日志
      {
        path: "logs",
        name: "Logs",
        component: () => import("../components/logs/Logs.vue"),
      },
      //字典管理
      {
        path: "dictionary",
        name: "Dictionary",
        component: () => import("../components/setup/Dictionary.vue"),
      },
      //SQL监控
      {
        path: "sql",
        name: "Sql",
        component: () => import("../components/setup/Sql.vue"),
      },
      //咨讯管理
      {
        path: "management",
        name: "Management",
        component: () => import("../components/management/Management.vue"),
      },
       //成交占比
       {
        path: "deal",
        name: "Deal",
        component: () => import("../components/kanban/Deal.vue"),
      },
       //产品占比
       {
        path: "product",
        name: "Product",
        component: () => import("../components/kanban/Product.vue"),
      },
       //理财占比
       {
        path: "financial",
        name: "Financial",
        component: () => import("../components/kanban/Financial.vue"),
      },
       //一周成交量
       {
        path: "week",
        name: "Week",
        component: () => import("../components/kanban/Week.vue"),
      },
       //今日成交量
       {
        path: "today",
        name: "Today",
        component: () => import("../components/kanban/Today.vue"),
      },
    ],
  },
];

const router = new VueRouter({
  routes,
});

export default router;
